<?php
include_once('classes/functionDb.php');

class XmlParser{
	
	public static function WriteDataToXml(){
		@include_once('../dbAction/DbConn.php');
		@include_once('./DbConn.php');
		$MyQuery = "SELECT * FROM users";
		$MyConn = DbConn::GetDbConn();
		$MyResult = $MyConn -> query($MyQuery);
		
		$MyConn->close();
		
		$MyWriter = new XMLWriter();
		
		$MyWriter -> openUri("C:\users.xml");
		$MyWriter -> startDocument("1.0");
		$MyWriter -> startElement("USERS");
		
		for ($i = 0; $row = $MyResult->fetch_row(); $i++){
			$MyWriter -> startElement("USER");
			
			$MyWriter -> startElement("USER_ID");
			$MyWriter -> text($row[0]);
			$MyWriter -> endElement();
			
			$MyWriter -> startElement("LOGIN");
			$MyWriter -> text($row[1]);
			$MyWriter -> endElement();
			
			$MyWriter -> startElement("DATA_REG");
			$MyWriter -> text($row[3]);
			$MyWriter -> endElement();
			
			$MyWriter -> startElement("NAME");
			$MyWriter -> text($row[4]);
			$MyWriter -> endElement();
			
			$MyWriter -> startElement("SURNAME");
			$MyWriter -> text($row[5]);
			$MyWriter -> endElement();
			
			$MyWriter -> startElement("EMAIL");
			$MyWriter -> text($row[6]);
			$MyWriter -> endElement();
			
			$MyWriter -> endElement();
		}
		
		$MyWriter -> endDocument();
	}
}

?>